package com.framework.dbs.orm.impl;

import com.framework.dbs.orm.IDialect;

public class OracleDialect implements IDialect {

	private String ORACLE_PAGEDSQL_FORMATTER;

    public OracleDialect() {
        ORACLE_PAGEDSQL_FORMATTER = 
        	"SELECT * FROM (SELECT A.*, ROWNUM RN FROM (%z%) A WHERE ROWNUM <= %x%) WHERE RN " +">= %y%";
    }

    public String getPagedString(String sql, boolean hasOffset) {
        return null;
    }

    public String getPagedString(String sql, int offset, int limit) {
        offset++;
        int endset = (offset + limit) - 1;
        String rs = ORACLE_PAGEDSQL_FORMATTER.replaceFirst("%z%", sql).replaceFirst("%y%", offset + "").replaceFirst("%x%", endset + "");
        return rs;
    }

    public boolean supportsPaged() {
        return true;
    }

}
